package com.example.demo.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.time.LocalDate;
import java.util.Set;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Table
@Entity
@EntityListeners(AuditingEntityListener.class)
public class Customer {


    private static int i=1;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private  Integer customerId;

    private String name/*="daishuo"+i++*/;


    @CreatedDate
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private LocalDate Birthday;


    private  String phonenumber;



    @JsonIgnore/*注意命名规范：首字母不能为大写，但是第二个单词开始可首字母以大写*/
    @OneToMany(mappedBy = "customer")
    private Set<Account> accounts;

    public Customer(String phonenumber) {
        this.phonenumber = phonenumber;
    }
}
